﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AcademicTermsControl.ascx.cs" Inherits="AcademicPlanner.Presentation.Views.Shared.AcademicTermsControl" %>

<%@ Import Namespace="AcademicPlanner.Framework.Helpers" %>
<%@ Import Namespace="AcademicPlanner.Presentation" %>
<%@ Import Namespace="AcademicPlanner.Presentation.Views.Shared" %>


<% if (!Model.IsSub)
   { %>
	<div class="academic-terms-control yui-skin-sam" id="<%= Model.Id %>">
<% } %>


<% if (Model.Mode == AcademicTermsControlMode.SELECT)
   { %>
		<div class="academic-terms-selection">
		<% var vSelectedTermIds = new List<string>(); %>
			<span class="select-courses link" onclick="gAcademicTermsControlCtrl.onSelectAcademicTermsClick(this)">
				<%= Tr("Select/Hide") %>
			</span>
			<div class="academic-terms">
			<% foreach (var vTerm in Model.AcademicTerms)
				{ %>
					<% 
					var vChecked = false;
					if (Model.SelectedAcademicTerms.Contains(vTerm))
					{
						vSelectedTermIds.Add(vTerm.EntityId.ToString());
						vChecked = true;
					}
					%>
					<div class="academic-term left right-indented">
						<%= Html.CheckBox(Model.Id + "AcademicTermCheck" + vTerm.EntityId, vChecked, new { value = vTerm.EntityId, onclick = "gAcademicTermsControlCtrl.onAcademicTermCheckClick(this)" })%>
						<%= Html.Label(Model.Id + "AcademicTermCheck" + vTerm.EntityId, vTerm.Name)%>
					</div>
				<% } %>
				<%= Html.ClearBreak() %>
			</div>
			<%= Html.Hidden(Model.SelectedAcademicTermsFieldName, string.Join(",", vSelectedTermIds.ToArray()))%>
		</div>
<% } %>

<% if (!Model.IsSub)
   { %>
		</div>
<% } %>